<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>

<style type="text/css">
    
</style>
<script type="text/javascript">
    var rowId;
    $('fbox_privilegeGrid .ui-reset , #refresh_privilegeGrid').click(function(){
        $("#privilegeGrid").jqGrid('setGridParam',{search:false});
        var postData = $("#privilegeGrid").jqGrid('getGridParam','postData');
        $.extend(postData,{searchField:"",searchString:"",searchOper:""});
        $.extend(postData,{filters:""});
        $("#privilegeGrid").trigger("reloadGrid");
    });

    function isError(text) {
        if(text.indexOf('ERROR') >= 0) { return [false, text]; }
        return [true,''];
    }
    
//    $.subscribe('editsuccess', function(event,data) {
//        $("#privilegeGrid").jqGrid('setGridParam',{search:false});
//        var postData = $("#privilegeGrid").jqGrid('getGridParam','postData');
//        $.extend(postData,{searchField:"",searchString:"",searchOper:""});
//        $.extend(postData,{filters:""});
//        $("#privilegeGrid").trigger("reloadGrid");
//    });
    
    
</script>
<%--<div class="gridOptsContainer">
    <sj:submit button="true" cssStyle="font-size:14px;" id="roleGrid_add" value="Add Role"/>
    <sj:submit button="true" cssStyle="font-size:14px"  id="roleGrid_delete" value="Delete Role"/>
</div>--%>
<s:url id="remoteurl" action="grid-privileges"/>
<s:url id="editurl" action="edit-privileges"/>
<sjg:grid
    id="privilegeGrid"
    caption="Cashmate Roles & Privileges"
    dataType="json"
    href="%{remoteurl}"
    gridModel="gridModel"
    scroll="true"
    rowNum="-1"
    loadingText="Requesting Data..."
    groupField="['utype']"
    groupColumnShow="[false]"
    groupCollapse="true"
    groupText="['<b>{0} - {1} Module(s)</b>']"
    width="970"
    shrinkToFit="true"
    pager="true"
    pagerButtons="false"
    pagerInput="false"
    hoverrows="true"
    rownumbers="true"
    autoencode="true"
    viewrecords="true"
    navigator="true"
    navigatorAdd="false"
    navigatorDelete="false"
    navigatorEdit="false"
    navigatorSearch="false"
    navigatorView="false"
    cellEdit="true"
    cellurl="%{editurl}"
    >

    <sjg:gridColumn name="usertypeModuleid"
                    index="usertypeModuleid"
                    title="usertype-module No."
                    sortable="false"
                    key="true"
                    hidden="true"/>

    <sjg:gridColumn name="modulename"
                    index="modulename"
                    title="Module"
                    sortable="true"
                    align="center"
                    />

    <sjg:gridColumn name="utype"
                    index="utype"
                    title="Role"
                    />

    <sjg:gridColumn name="rewordViewable"
                    index="rewordViewable"
                    title="Viewable"
                    editable="true"
                    edittype="checkbox"
                    align="center"
                    />

    <sjg:gridColumn name="rewordEditable"
                    index="rewordEditable"
                    title="Editable"
                    editable="true"
                    edittype="checkbox"
                    align="center"
                    />

    <sjg:gridColumn name="rewordCreateable"
                    index="rewordCreateable"
                    title="Createable"
                    editable="true"
                    edittype="checkbox"
                    align="center"
                    />

    <sjg:gridColumn name="rewordDeleteable"
                    index="rewordDeleteable"
                    title="Deleteable"
                    editable="true"
                    edittype="checkbox"
                    align="center"
                    />
</sjg:grid>

